﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WindowsFormsApp1.SQlite;

namespace WindowsFormsApp1
{
    public partial class FormMain : Form
    {
        private frmEmployee frmEmployeeWindow;
        private frmResume frmResumeWindow;
        public FormMain()
        {
            InitializeComponent();
            int titleheight = 30;
            //this.StartPosition = FormStartPosition.Manual;
            
            //this.Location = new Point(this.Location.X, 0);
            this.Height = System.Windows.Forms.Screen.AllScreens[0].WorkingArea.Height - titleheight;
            this.StartPosition = FormStartPosition.CenterScreen;
            //左边列表
            frmEmployeeWindow = new frmEmployee();
            frmEmployeeWindow.TopLevel = false;
            frmEmployeeWindow.Parent = this;
            frmEmployeeWindow.Location = new Point(0, 0);
            frmEmployeeWindow.Height = System.Windows.Forms.Screen.AllScreens[0].WorkingArea.Height- titleheight;
            frmEmployeeWindow.Show();
            frmEmployeeWindow.addResumeClick += AddResumeClick;
            frmEmployeeWindow.deleteResumeClick += DeleteResumeClick;
            frmEmployeeWindow.Callback += ReceivePersonModel;
            //右边
            frmResumeWindow = new frmResume();
            frmResumeWindow.TopLevel = false;
            frmResumeWindow.Parent = this;
            frmResumeWindow.Location = new Point(frmEmployeeWindow.Width, 0);
            frmResumeWindow.Height = System.Windows.Forms.Screen.AllScreens[0].WorkingArea.Height- titleheight -40;
            frmResumeWindow.Show();
        }
        /// <summary>
        /// 新增简历
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddResumeClick(object sender, EventArgs e)
        {
            frmResumeWindow.clearEmptyAllControl();
        }
        /// <summary>
        /// 删除简历
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteResumeClick(object sender, EventArgs e)
        {
            frmResumeWindow.deleteResume();
            
        }
        private void ReceivePersonModel(PersonModel personModel)
        {
            PersonModel pm = DbOperate.Instance.GetPersonByGuid(personModel.guid);
            if (pm is null) return;
            frmResumeWindow.editResume(pm);
        }
    }
}
